<?php

class User {

    private $id;
    private $name;

    //more fields here

    public function __construct($id = null) {
        $this->id = $id;
        if (!is_null($this->id)) {
            $this->load_user_data();
        }
    }

    protected function load_user_data() {
        //select from DB where id = $this->id and populate fields
    }

    public function save() {
        //if $this->id is null insert the user details in DB and populate $this->id with new user's id
        //else update DB with field (optionally check what has changed and update only if necessary)
    }

}
